@extends('front.layout')
@section('title','名家讲堂')
@section('class','class=current')
@section('content')
    <div class="online">
        <div class="online_class">
            <div class="online_class_bg"><img src="/assets/images/last_time_bg.jpg"></div>

            <div class="online_class_body">
                @if($cnt>0)
                    <?php
                    $start = \Illuminate\Support\Carbon::parse($oVideo->start_at);
                    $now = \Illuminate\Support\Carbon::now();
                    $end = \Illuminate\Support\Carbon::parse($oVideo->end_at);//取结束时间
                    ?>
                    @if($now < $start)
                        <div class="before">
                            <div class="last_time_big">
                                <span class="time1"></span>
                                <span class="time2"></span>
                                <span class="time3"></span>
                                <span class="time4"></span>
                            </div>
                            <a class="class_href" href="#"></a>
                        </div>

                            <div class="online_export_box">
                                <div class="online_export_bg"></div>
                                <div class="online_export clearfix">
                                    <div class="online_export_ship">
                                        @foreach($oVideo->experts as $expert)
                                        <div class="online_export_img">
                                            <a href="#"><img src="{{$expert->thumb}}"></a>
                                        </div>
                                        <div class="online_export_txt">

                                            <p>专家：{{$expert->name}}</p>
                                            <p>医院：{{$expert->hospital}}</p>
                                            <p>科室：{{$expert->department}}</p>
                                            <p>职称：{{$expert->position}}</p>
                                            <?php break;?>@endforeach
                                        </div>
                                    </div>

                                    <!--课程简介-->
                                    <div class="online_export_ship border_left">
                                        <div class="online_export_intro">
                                            <p><b>课程简介</b></p>
                                            <?php echo $oVideo->profile?>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        @elseif($now > $end)
                        <!--会议结束-->
                            <div class="end_title">会议已结束</div>

                        @else
                        <!--会议进行中-->
                            <input type="hidden" id="url" value="{{$oVideo->website}}">
                            <div id="meeting" class="meeting" >
                                <a href="javascript:Pop_on_input()">
                                    <img src="assets/images/online_classing.png" />
                                </a>
                            </div>
                        @endif

                @else
                <!--会议结束-->
                    <div class="end_title">已无直播</div>
                @endif
            </div>
        </div>

        <div class="online_class_share">
            <span>分享到：</span>
            <a href="javascript:void(0)" onclick="erweima()"><img src="/assets/images/icon_weixin.jpg"/></a>
        </div>

    </div>

    <script>
        var starttime = new Date('{{$cnt>0?$oVideo->start_at:''}}');
        var endtime =new Date('{{$cnt>0?$oVideo->end_at:''}}');
        function count_down() {
            var nowtime = new Date();
            var time = starttime - nowtime;
            var time2=endtime-nowtime;
            if(time<=0 && time2<=0){
                clearInterval(id);

            }
            var day = parseInt(time / 1000 / 60 / 60 / 24);
            var hour = parseInt(time / 1000 / 60 / 60 % 24);
            var minute = parseInt(time / 1000 / 60 % 60);
            var seconds = parseInt(time / 1000 % 60);

            var day1 = parseInt(time2 / 1000 / 60 / 60 / 24);
            var hour1 = parseInt(time2 / 1000 / 60 / 60 % 24);
            var minute1= parseInt(time2 / 1000 / 60 % 60);
            var seconds1 = parseInt(time2 / 1000 % 60);


            $('.time1').html(day);
            $('.time2').html(hour);
            $('.time3').html(minute);
            $('.time4').html(seconds);
            if(day==0&&hour==0&&minute==0&&seconds==0){
                location.reload();
            }
            if(day1==0&&hour1==0&&minute1==0&&seconds1==0){
                location.reload();
            }
        }
        var id = setInterval(count_down, 1000);
    </script>
    <div id="char_pop" class="chat_pop" style="display: none">
        <div id="char_close" class="chat_pop_top"><a onclick="Pop_close()" class="chat_pop_close"></a></div>
        <div class="chat_pop_body">
            <img src="/assets/images/1.png" />
            <p>使用微信扫一扫，并将网页分享给好友</p>
        </div>
    </div>
    <!-- 姓名输入弹出框 -->
    <div id="name_pop" class="export_pop" style="display:none">
        <div class="export_pop_top">
            <span>提示</span>
            <a href="javascript:Pop_close()" class="export_pop_close"></a>
        </div>
        <div class="export_pop_body">
            <div>请输入您的姓名：</div>
            <div class="export_name_input"><input id="nick_name" type="text" /></div>
            <div class="export_name_submit"><input type="button" class="btn blue_btn" value="确定" onclick="join_meeting()"/></div>
        </div>
    </div>
    <!--微信引导页-->
    <div id="cover" class="phone_page" style="display: none">
        <div class="phone_top"><img src="assets/images/top.png" /></div>
        <div class="know"><a href="javascript:quit_pop()"><img src="assets/images/btn_bg.png" /></a></div>
    </div>
    <script>
        function erweima(){
            $.blockUI({
                message:$("#char_pop"),
                css:{border:'none'}
            });
        }
        function Pop_on_input()
        {
            $.blockUI({
                message: $("#name_pop"),
                css:{border:'none' }
            });
        }
        function Pop_close(){
            $.unblockUI();
        }
    </script>
@endsection
